#include "miniwindow.h"
#include "ui_miniwindow.h"
#include "klinegrid.h"
#include "kvolumegrid.h"
#include <QSplitter>

MiniWindow::MiniWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MiniWindow)
{
    ui->setupUi(this);

    pgrid = new KVolumeGrid(this);
    pgrid->setObjectName(tr("kline"));
    pgrid->setFocusPolicy(Qt::StrongFocus);

    auto p2 = new KLineGrid(this);
    p2->setFocusPolicy(Qt::StrongFocus);

    // setCentralWidget(pgrid);

    QSplitter *splitterMain = new QSplitter(Qt::Vertical, 0); //新建主分割窗口，水平分割
    QSplitter *splitterLeft = new QSplitter(Qt::Vertical, splitterMain);
    QSplitter *splitterRight = new QSplitter(Qt::Vertical, splitterMain);


    splitterMain->setHandleWidth(1);

    splitterLeft->addWidget(p2);
    splitterRight->addWidget(pgrid);
    this->setCentralWidget(splitterMain);


    resize(600,800);
}

MiniWindow::~MiniWindow()
{
    delete ui;
}

void MiniWindow::exec()
{
    setWindowModality(Qt::ApplicationModal);
    show();
    m_eventLoop->exec();
}

void MiniWindow::closeEvent(QCloseEvent *event)
{
    /*
         * TODO 它可代替 TbarClose_Click 的功能
         */
        m_eventLoop->exit();
        return QMainWindow::closeEvent(event);
}
